import React from 'react'
import indexStyle from '../index.less'
import { techClassification } from '../public/common'
import { DownOutlined, UpOutlined } from '@ant-design/icons'

class TechClassification extends React.PureComponent {
  constructor (props) {
    super(props)
    this.state = {
      // false为未展开图标，朝下
      // true为展开图标，朝上
      bottomIcon: false
    }
  }

  changeBottomIcon = (e) => {
    // 一般事件都是冒泡
    const { bottomIcon } = this.state
    this.setState({
      bottomIcon: !bottomIcon
    })
  }

  render () {
    const { bottomIcon } = this.state
    return (
      <div
        className={indexStyle.contentTop}
        // 移入和移出
        onMouseEnter={this.changeBottomIcon}
        onMouseLeave={this.changeBottomIcon}
      >
        <ul
          className={indexStyle.techListStyle}
        >
          {
            techClassification.map(item => {
              return <li key={item.key}>{item.value}</li>
            })
          }
        </ul>
        <div
          className={indexStyle.bottomIconStyle}
        >
          {bottomIcon ? <UpOutlined/> : <DownOutlined/>}
        </div>
      </div>
    )
  }
}

export default TechClassification
